//加密算法

public class Encrypy {
    String encrpy(String mingwen,int miyao) throws exp1Exception {
        char[] c = mingwen.toCharArray();
        int a = c.length;
        for(int i=0;i<a;i++) {
            if ((c[i] >= 'a' && c[i] <='z') || (c[i] >= 'A' && c[i] <= 'Z')) {     //判断是否为英文字母
                if(c[i] >= 'a' && c[i] <='z') {     //加密
                    c[i] = (char) ( (c[i] - 'a'+ miyao) % 26 + 'a');
                }
                else {
                    c[i] = (char) ( (c[i] - 'A'+ miyao) % 26 + 'A');
                }
            } else {
                throw new exp1Exception(mingwen);
            }
        }
        return new String(c);     //返回密文
    }
}
